All Questions
13 questions
3votes
1answer
363views
Python function to find the count of digits of numerals in base n up to a given limit
This is a simple exercise to find the count of digits of all numerals in a given base up to a given limit (not including the limit), I wrote it to determine the ratio of bytes saved when the numbers ...
6votes
4answers
621views
Pascal Triangle calculation with BigIntegers
On a well known programming challenges website(CW) there is a Kyu2 eggs height problem that can be solved utilizing a variation of Pascals Triangles properties. The problem asks to solve ...
5votes
2answers
882views
HackerRank - Non-Divisible Subset
In this problem we are asked: Given a set, S, of n distinct integers, print the size of a maximal subset, S', of where the sum of any two numbers in it is not evenly divisible by k. Code My idea is ...
2votes
1answer
2kviews
Finding the maximum GCD of all pairs
The code below is for Hackerrank competition. Seems that it works correctly but performs very slowly and because of it can't pass some tests. The task is to find the maximum GCD of all possible pairs ...
4votes
3answers
6kviews
Google Foobar bomb_baby
This is the question I am facing at level 3 of Google Foobar: There are two types: Mach bombs (M) and Facula bombs (F). The bombs, once released into the LAMBCHOP's inner workings, will ...
2votes
2answers
9kviews
Count the number of ways an integer can be represented as a sum of consecutive positive integers
I am trying to count the number of ways an integer can be represented as sum of 2 or more consecutive positive integers. My Code is working in under 1 second for small inputs (\$\le 10^7\$) but after ...
3votes
2answers
592views
Time limit exceeded on finding out the GCD and LCM of a Python list
I'm doing this HackerRank problem: Consider two sets of positive integers, \$A=\{a_0, a_1, \ldots, a_{n-1}\}\$ and \$B=\{b_0, b_1, \ldots, b_{m-1}\}\$. We say that a positive integer, \$x\$, is ...
3votes
1answer
2kviews
Project Euler #549: Divisibility of factorials
This is the problem: Calculate $$\sum_{i=2}^{10^8} s(i)$$ where \$s(n)\$ is the smallest \$m\$ such that \$n\$ divides \$m!\$. Quite mathematical, I've found a better way than brute force ...
3votes
2answers
457views
Mystery sum with placeholder digits
I came across this coding problem. Back in primary school, maybe you were sometimes asked to solve a fill-in-the-blank sum - or "mystery sum" - in which certain digits are removed and you had to ...
7votes
3answers
262views
Project Euler #5 (LCM 1 - 20) Follow up
I'm actually spending time on it, unlike the first time and going through, understanding and implementing the several suggestions I've landed on two different approaches. Approach 1: Employing Java 8 ...
5votes
4answers
5kviews
Project Euler #5 (LCM of 1-20)
Challenge: 2520 is the smallest number divisible by 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by 1-20? Solution: ...
5votes
4answers
2kviews
Project Euler #5 - Lowest common multiple of 1 through 20
This is my code. All comments welcome. Last time run it only took 335 milliseconds: ...
5votes
1answer
1kviews
Speed up lights-out variant solver in pure Python
I'm doing some challenges to learn new and interesting concepts, this one is about a Lights out variant, instead of toggling only the adjacent tiles, it toggles the whole row and col. It must be ...